Teacher Attrition

Row

---
title: "Research Associate Task"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: scroll
    theme: 
      version: 4
      bg: "#101010"
      fg: "#101010" 
      primary: "#ED79F9"
      navbar-bg: "#3ADAC6"
---

```{r setup, include=FALSE}
library(flexdashboard)
```

```{r, include=FALSE}
library(tidyverse)
library(here)
library(janitor)
library(rio)
library(colorblindr)
library(gghighlight)
library(forcats)
library(ggrepel)
library(gt)
library(knitr)
library(kableExtra)
library(reactable)
library(plotly)
library(glue)
library(fs)
library(rstatix)
library(ggpubr)
library(writexl)
library(remotes)
library(profvis)

theme_set(theme_minimal(15) +
            theme(legend.position = "bottom",
                  panel.grid.major.x = element_line(colour = "gray60"),
                  panel.grid.minor.x = element_blank(),
                  panel.grid.major.y = element_blank())
          )

```

```{r, include=FALSE}
teach_data <- import(here("data", "teacher_salary.sav"),
               setclass = "tbl_df") %>% 
  characterize() %>% 
  janitor::clean_names() %>% 
  mutate(district = as.factor(district))


str(teach_data)
```


# Teacher Attrition

Sidebar {.sidebar}
------------

Between the years 2015-2021, the average rate of teachers leaving school districts per year were as follows: 

  * Central City District: 13.06%
  * Douglas Unified Schools: 8.64%
  * Garden Grove Schools: 27.60%
  * Jackson City Schools: 15.23%

```{r, include=FALSE}
leave_avg <- teach_data %>% 
  group_by(district) %>% 
  summarize(mean(teachers_leaving))

```

Row {.tabset}
-----------------------------------------------------------------------

```{r, include=FALSE}
central <- teach_data %>% 
  filter(district == "Central City District")

leave_plot <- ggplot(teach_data, aes(year, teachers_leaving)) +
  geom_line(lwd = 1.6,
            color = "gray80") +
  geom_point(size = 2.5,
             color = "magenta") +
  scale_x_continuous(limits = c(2015, 2021),
                     breaks = c(2015, 2016, 2017, 2018, 2019, 2020, 2021)) +
  scale_y_continuous(limits = c(0, .40),
                     breaks = c(0, .10, .20, .30, .40),
                     "Teachers Leaving District",
                     labels = scales::percent) + 
  geom_text_repel(aes(label = scales::percent(teachers_leaving)),
                  size = 3.25) + 
  geom_area(fill = "cornflowerblue",
            alpha = 0.3) +
  facet_wrap(~district) +
  labs(x = "Year")
  

```

```{r, include=TRUE, fig.width=12, fig.height=7}
leave_plot
```